<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta property="og:type" content="website">
<meta property="og:title" content="smallmuou&#39;s blog">
<meta property="og:url" content="http://smallmuou.gitee.io/blog/page/19/index.html">
<meta property="og:site_name" content="smallmuou&#39;s blog">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="smallmuou&#39;s blog">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://smallmuou.gitee.io/blog/page/19/"/>





  <title>smallmuou's blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">smallmuou's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"><a href="https://github.com/smallmuou">https://github.com/smallmuou</a></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/blog/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/03/18/2015-03-18-iOS Safiri如何播放网页中的视频/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/03/18/2015-03-18-iOS Safiri如何播放网页中的视频/" itemprop="url">iOS Safiri如何播放网页中的视频</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-03-18T00:00:00+08:00">
                2015-03-18
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/IOS/" itemprop="url" rel="index">
                    <span itemprop="name">IOS</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>众所周知，网页中的视频一般是基于flash的，而接触过iOS的人，应该都知道，iOS的safari是不支持的flash，至于iOS为何不支持flash，可以查考<a href="http://www.zhihu.com/question/19609079" target="_blank" rel="noopener">这里</a>. 那如何支持视频呢？对，就是html5的video，iOS safari已经支持了html5的video. 于是第三方视频网站要实现的就是提供带video的html，这样iOS设备才有办法播放.</p>
<h2 id="兼容iOS"><a href="#兼容iOS" class="headerlink" title="兼容iOS"></a>兼容iOS</h2><p>视频网站要兼容iOS设备，那必须知道客户端是否是iOS设备，这个可以通过user-agent来判断，于是在PC上的浏览器可以通过设置user-agent来模拟iOS浏览器. 既然可以识别出客户端，那接下来的工作就是根据客户端的不同，提供不同的html，对于iOS用户，提供带有video的html，而对于其他客户端，则保留原来的方式.</p>
<h2 id="HTML5的video标签"><a href="#HTML5的video标签" class="headerlink" title="HTML5的video标签"></a>HTML5的video标签</h2><p>HTML5可谓是下一代HTML，其在HTML的基础上增加了很多特性，其中支持多媒体就是其中之一，多媒体包括音频、视频等，接下来介绍下视频标签.</p>
<pre>
< video src="movie.ogg" controls="controls"> < /video>
</pre>
上述中是video标签的简单例子，其中src就指明了视频源.视频源可以是mp4、ts、m3u8等

## m3u8
也许很多人都不熟悉m3u8，当然也包括我，m3u8实际不是一个视频编码格式，而仅仅是一种播放多媒体列表的文件格式. m3u8是Unicode版本的m3u，用UTF-8编码。"M3U"和"M3U8"文件都是苹果公司使用的HTTP Live Streaming格式的基础，这种格式可以在iPhone和Macbook等设备播放。

m3u8文件是一个纯文本文件，可以指定多个多媒体的位置.

* \#EXTM3U - 文件的头部，必须是文件的第一行
* \#EXTINF - 指示多媒体文件的信息，包括播放时间和标题

下面来看下m3u8的文件DEMO:
<pre>
\#EXTM3U
\#EXT-X-TARGETDURATION:12
\#EXT-X-VERSION:2
\#EXTINF:6,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=0&ts_end=5.906&ts_seg_no=0&ts_keyframe=1
\#EXTINF:5,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=5.906&ts_end=10.661&ts_seg_no=1&ts_keyframe=1
\#EXTINF:6,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=10.661&ts_end=16.667&ts_seg_no=2&ts_keyframe=1
\#EXTINF:10,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=16.667&ts_end=27.136&ts_seg_no=3&ts_keyframe=1
\#EXTINF:9,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=27.136&ts_end=36.019&ts_seg_no=4&ts_keyframe=1
\#EXTINF:12,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=36.019&ts_end=47.823&ts_seg_no=5&ts_keyframe=1
\#EXTINF:10,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=47.823&ts_end=58.083&ts_seg_no=6&ts_keyframe=1
\#EXTINF:10,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=58.083&ts_end=67.843&ts_seg_no=7&ts_keyframe=1
\#EXTINF:8,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=67.843&ts_end=75.684&ts_seg_no=8&ts_keyframe=1
\#EXTINF:11,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=75.684&ts_end=86.862&ts_seg_no=9&ts_keyframe=1
\#EXTINF:8,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=86.862&ts_end=94.786&ts_seg_no=10&ts_keyframe=1
\#EXTINF:11,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=94.786&ts_end=105.672&ts_seg_no=11&ts_keyframe=1
\#EXTINF:11,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=105.672&ts_end=116.892&ts_seg_no=12&ts_keyframe=1
\#EXTINF:12,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=116.892&ts_end=128.529&ts_seg_no=13&ts_keyframe=1
\#EXTINF:11,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=128.529&ts_end=139.998&ts_seg_no=14&ts_keyframe=1
\#EXTINF:12,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=139.998&ts_end=151.552&ts_seg_no=15&ts_keyframe=1
\#EXTINF:8,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=151.552&ts_end=159.643&ts_seg_no=16&ts_keyframe=1
\#EXTINF:11,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=159.643&ts_end=171.071&ts_seg_no=17&ts_keyframe=1
\#EXTINF:12,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=171.071&ts_end=182.624&ts_seg_no=18&ts_keyframe=1
\#EXTINF:11,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=182.624&ts_end=193.802&ts_seg_no=19&ts_keyframe=1
\#EXTINF:11,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=193.802&ts_end=204.396&ts_seg_no=20&ts_keyframe=1
\#EXTINF:11,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=204.396&ts_end=215.324&ts_seg_no=21&ts_keyframe=1
\#EXTINF:12,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=215.324&ts_end=226.918&ts_seg_no=22&ts_keyframe=1
\#EXTINF:11,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=226.918&ts_end=237.888&ts_seg_no=23&ts_keyframe=1
\#EXTINF:12,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=237.888&ts_end=249.691&ts_seg_no=24&ts_keyframe=1
\#EXTINF:11,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=249.691&ts_end=260.327&ts_seg_no=25&ts_keyframe=1
\#EXTINF:9,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=260.327&ts_end=269.711&ts_seg_no=26&ts_keyframe=1
\#EXTINF:4,
http://121.12.89.21/6772086E552337397BF87488A/0300080100546C4E8E39C501DB0DC93150BCFB-DFBD-8638-4B96-9661586BFA43.mp4?ts_start=269.711&ts_end=273.34&ts_seg_no=27&ts_keyframe=1
\#EXT-X-ENDLIST

</pre>

<h2 id="综述"><a href="#综述" class="headerlink" title="综述"></a>综述</h2><p>于是，iOS设备播放在线视频原理是视频网站通过user-agent来适配并提供带video标签的html，video的src设置为视频列表文件源，即m3u8，iOS获取到相应的m3u8文件后，从而播放其中的视频链接.</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/03/01/2015-03-01-ping解读/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/03/01/2015-03-01-ping解读/" itemprop="url">ping解读</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-03-01T00:00:00+08:00">
                2015-03-01
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/SHELL/" itemprop="url" rel="index">
                    <span itemprop="name">SHELL</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>提到ping命令，相信大部分人都用过，比如要查一下IP，ping之；查一下网关，ping之；查一下网络状态，ping之. 由此可见，ping虽小，但却精悍. 下面我们来解读ping之原理.</p>
<p><pre><br>92 bytes from 192.168.60.147: Destination Host Unreachable<br>Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst<br> 4  5  00 5400 76e4   0 0000  3f  01 4571 192.168.1.108  192.168.60.151<br></pre></p>
<ul>
<li>Vr - 版本（ipv4、ipv6）</li>
<li>HL - IP头长度</li>
<li>TOS - 服务类型字段: 服务类型(TOS)字段包括一个3 bit的优先权子字段(现在已被忽略)，4 bit的TOS子字段和1 bit未用位但必须置0。4 bit的TOS子字段分别代表:最小时延、最大吞吐量、最高可靠性和最<br>小费用。4 bit中只能设置其中1 bit。如果所有4 bit均为0,那么就意味着是一般服务。</li>
<li>Len - IP数据报长度</li>
<li>ID - 表示数据报，通常每发送一份报文它的值就会加1</li>
<li>Flg - 分段偏移(Fragment offset)域的高3位，比特0是保留的，必须为0；比特1是“更多分片”(MF – More Fragment)标志。除了最后一片外，其他每个组成数据报的片都要把该比特置1。比特2是“不分片”(DF – DonDon’t Fragment)标志,如果将这一比特置1，IP将不对数据报进行分片,这时如果有需要进行分片的数据报到来，会丢弃此数据报并发送一个ICMP差错报文给起始端。</li>
<li>off - 分段偏移(Fragment offset)域的低13位</li>
<li>TTL - 存活时间, TTL是IP协议包中的一个值，它告诉网络路由器包在网络中的时间是否太长而应被丢弃。 即经过的最大节点数目</li>
<li>Pro - 协议族</li>
<li>cks - 校验码</li>
<li>Src - 源</li>
<li>Dst - 目的</li>
</ul>
<p>ping 使用的是<a href="http://www.ietf.org/rfc/rfc792.txt" target="_blank" rel="noopener">ICMP</a>协议，ICMP(Internet Control Message Protocol)是介于网络层和传输层的协议。它的主要功能是传输网络诊断信息。<br>ICMP传输的信息可以分为两类，一类是错误(error)信息，这一类信息可用来诊断网络故障。我们已经知道，IP协议的工作方式是“Best Effort”，如果IP包没有被传送到目的地，或者IP包发生错误，IP协议本身不会做进一步的努力。但上游发送IP包的主机和接力的路由器并不知道下游发生了错误和故障，它们可能继续发送IP包。通过ICMP包，下游的路由器和主机可以将错误信息汇报给上游，从而让上游的路由器和主机进行调整。需要注意的是，ICMP只提供特定类型的错误汇报，它不能帮助IP协议成为“可靠”(reliable)的协议。另一类信息是咨询(Informational)性质的，比如某台计算机询问路径上的每个路由器都是谁，然后各个路由器同样用ICMP包回答。</p>
<p>(ICMP基于IP协议。也就是说，一个ICMP包需要封装在IP包中，然后在互联网传送。ICMP是IP套装的必须部分，也就是说，任何一个支持IP协议的计算机，都要同时实现ICMP。)<br><a href="http://www.cnblogs.com/vamei/archive/2012/12/05/2801991.html" target="_blank" rel="noopener">ICMP包</a>都会有Type, Code和Checksum三部分。Type表示ICMP包的大的类型，而Code是一个Type之内细分的小类型。针对不同的错误信息或者咨询信息，会有不同的Type和Code。从上面我们可以看到，ICMP支持的类型非常多，就好像瑞士军刀一样，有各种各样的功能。Checksum与IP协议的header checksum相类似，但与IP协议中checksum只校验头部不同，这里的Checksum所校验的是整个ICMP包(包括头部和数据)。</p>
<p><img src="http://g.hiphotos.baidu.com/baike/s%3D250/sign=4e8661dcf8f2b211e02e824bfa816511/ae51f3deb48f8c54ca50c28039292df5e1fe7f99.jpg" alt="image"></p>
<table>
<thead>
<tr>
<th style="text-align:left">TYPE</th>
<th style="text-align:left">CODE</th>
<th style="text-align:left">Description</th>
<th style="text-align:left">Query</th>
<th style="text-align:left">Error</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">0</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Echo Reply——回显应答（Ping应答）</td>
<td style="text-align:left">x</td>
<td style="text-align:left">　</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Network Unreachable——网络不可达</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">1</td>
<td style="text-align:left">Host Unreachable——主机不可达</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">2</td>
<td style="text-align:left">Protocol Unreachable——协议不可达</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">3</td>
<td style="text-align:left">Port Unreachable——端口不可达</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">4</td>
<td style="text-align:left">Fragmentation needed but no frag. bit set——需要进行分片但设置不分片比特</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">5</td>
<td style="text-align:left">Source routing failed——源站选路失败</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">6</td>
<td style="text-align:left">Destination network unknown——目的网络未知</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">7</td>
<td style="text-align:left">Destination host unknown——目的主机未知</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">8</td>
<td style="text-align:left">Source host isolated (obsolete)——源主机被隔离（作废不用）</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">9</td>
<td style="text-align:left">Destination network administratively prohibited——目的网络被强制禁止</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">10</td>
<td style="text-align:left">Destination host administratively prohibited——目的主机被强制禁止</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">11</td>
<td style="text-align:left">Network unreachable for TOS——由于服务类型TOS，网络不可达</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">12</td>
<td style="text-align:left">Host unreachable for TOS——由于服务类型TOS，主机不可达</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">13</td>
<td style="text-align:left">Communication administratively prohibited by filtering——由于过滤，通信被强制禁止</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">14</td>
<td style="text-align:left">Host precedence violation——主机越权</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:left">15</td>
<td style="text-align:left">Precedence cutoff in effect——优先中止生效</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">4</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Source quench——源端被关闭（基本流控制）    　    　</td>
</tr>
<tr>
<td style="text-align:left">5</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Redirect for network——对网络重定向    　    　</td>
</tr>
<tr>
<td style="text-align:left">5</td>
<td style="text-align:left">1</td>
<td style="text-align:left">Redirect for host——对主机重定向    　    　</td>
</tr>
<tr>
<td style="text-align:left">5</td>
<td style="text-align:left">2</td>
<td style="text-align:left">Redirect for TOS and network——对服务类型和网络重定向</td>
</tr>
<tr>
<td style="text-align:left">5</td>
<td style="text-align:left">3</td>
<td style="text-align:left">Redirect for TOS and host——对服务类型和主机重定向</td>
</tr>
<tr>
<td style="text-align:left">8</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Echo request——回显请求（Ping请求）</td>
<td style="text-align:left">x</td>
<td style="text-align:left">　</td>
</tr>
<tr>
<td style="text-align:left">9</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Router advertisement——路由器通告    　    　</td>
</tr>
<tr>
<td style="text-align:left">10</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Route solicitation——路由器请求    　    　</td>
</tr>
<tr>
<td style="text-align:left">11</td>
<td style="text-align:left">0</td>
<td style="text-align:left">TTL equals 0 during transit——传输期间生存时间为0</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">11</td>
<td style="text-align:left">1</td>
<td style="text-align:left">TTL equals 0 during reassembly——在数据报组装期间生存时间为0</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">12</td>
<td style="text-align:left">0</td>
<td style="text-align:left">IP header bad (catchall error)——坏的IP首部（包括各种差错）</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">12</td>
<td style="text-align:left">1</td>
<td style="text-align:left">Required options missing——缺少必需的选项</td>
<td style="text-align:left"></td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">13</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Timestamp request (obsolete)——时间戳请求（作废不用）</td>
<td style="text-align:left">x　</td>
</tr>
<tr>
<td style="text-align:left">14</td>
<td style="text-align:left"></td>
<td style="text-align:left">Timestamp reply (obsolete)——时间戳应答（作废不用）</td>
<td style="text-align:left">x　</td>
</tr>
<tr>
<td style="text-align:left">15</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Information request (obsolete)——信息请求（作废不用）</td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">16</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Information reply (obsolete)——信息应答（作废不用）</td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">17</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Address mask request——地址掩码请求</td>
<td style="text-align:left">x</td>
</tr>
<tr>
<td style="text-align:left">18</td>
<td style="text-align:left">0</td>
<td style="text-align:left">Address mask reply——地址掩码应答    　    　</td>
</tr>
</tbody>
</table>
<h5 id="用ping测试网络连通"><a href="#用ping测试网络连通" class="headerlink" title="用ping测试网络连通"></a>用ping测试网络连通</h5><ul>
<li>ifconifg查看网络设置</li>
<li>ping 127.0.0.1 检查本地TCP/IP协议是否OK</li>
<li>ping 本机IP地址，检查本机网卡是否OK</li>
<li>ping 网关，检查本地局域网是否OK</li>
<li>ping DNS，检查是否可以进行域名解析</li>
<li>ping 远程IP，检查是否可以连接Internet</li>
</ul>
<h5 id="0省略"><a href="#0省略" class="headerlink" title=".0省略"></a>.0省略</h5><ul>
<li>ping 127.0.0.1 = ping 127.1</li>
<li>ping 127.0.1.1 != ping 127.1.1</li>
</ul>
<h5 id="ttl妙用"><a href="#ttl妙用" class="headerlink" title="ttl妙用"></a>ttl妙用</h5><ul>
<li>traceroute命令就是利用ttl来实现<ul>
<li>IPv4中的Time to Live(TTL)和IPv6中的Hop Limit会随着经过的路由器而递减，当这个区域值减为0时，就认为该IP包超时(Time Exceeded)。Time Exceeded就是TTL减为0时的路由器发给出发主机的ICMP包，通知它发生了超时错误。<br>traceroute就利用了这种类型的ICMP包。traceroute命令用来发现IP接力路径(route)上的各个路由器。它向目的地发送IP包，第一次的时候，将TTL设置为1，引发第一个路由器的Time Exceeded错误。这样，第一个路由器回复ICMP包，从而让出发主机知道途径的第一个路由器的信息。随后TTL被设置为2、3、4，…，直到到达目的主机。这样，沿途的每个路由器都会向出发主机发送ICMP包来汇报错误。traceroute将ICMP包的信息打印在屏幕上，就是接力路径的信息了。</li>
</ul>
</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/02/16/2015-02-16-wget进度条显示原理/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/02/16/2015-02-16-wget进度条显示原理/" itemprop="url">wget进度条显示原理</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-02-16T00:00:00+08:00">
                2015-02-16
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/SHELL/" itemprop="url" rel="index">
                    <span itemprop="name">SHELL</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>每次使用wget下载内容时，会发现进度条都是当行一直更新，而在c中打印都是printf，这个似乎没有此功能；今天查了下，发现printf \n 是另起一行，\r是回到本行的开头，如果继续输入的话，则覆盖之前的内容，如下是个DEMO:</p>
<pre>
include < stdio.h>
include < stdlib.h>
include < unistd.h>

//类似wget的进度条的实现，实际就是转移符\r的使用，\r的作用是返回至行首而不换行
int main(int argc, char *argv[])
{
    unsigned len = 60;
    char *bar = (char *)malloc(sizeof(char) * (len + 1));
    for (int i = 0; i < len + 1; ++i)
    {
        bar[i] = '#';
    }
    for (int i = 0; i < len; ++i)
    {
        printf("progress:[%s]%d%%\r", bar+len-i, i+1);
        fflush(stdout);//一定要fflush，否则不会会因为缓冲无法定时输出。
        usleep(100000);
        //sleep(1);
    }
    printf("\n");
    return 0;
}
</pre>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/02/06/2015-02-06-iOS 摄像头操作/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/02/06/2015-02-06-iOS 摄像头操作/" itemprop="url">iOS 摄像头操作</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-02-06T00:00:00+08:00">
                2015-02-06
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/IOS/" itemprop="url" rel="index">
                    <span itemprop="name">IOS</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>通过[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]可以获取到所有摄像头设备</p>
<pre>
"AVCaptureFigVideoDevice: 0x14fd07620 [Back Camera][com.apple.avfoundation.avcapturedevice.built-in_video:0]",
    "AVCaptureFigVideoDevice: 0x14fd079e0 [Front Camera][com.apple.avfoundation.avcapturedevice.built-in_video:1]",
</pre>
PS: 从上面可以看出分别包含后置摄像头、前置摄像头

## 摄像头数据获取及显示
<pre>
- (void)initCapture {
    AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput
                                          deviceInputWithDevice:[AVCaptureDevice
                                                                 devicesWithMediaType:AVMediaTypeVideo][1]  error:nil];
    AVCaptureVideoDataOutput *captureOutput = [[AVCaptureVideoDataOutput alloc]
                                               init];
    captureOutput.alwaysDiscardsLateVideoFrames = YES;
    //captureOutput.minFrameDuration = CMTimeMake(1, 10);

    dispatch_queue_t queue;
    queue = dispatch_queue_create("cameraQueue", NULL);
    [captureOutput setSampleBufferDelegate:self queue:queue];
    NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey;
    NSNumber* value = [NSNumber
                       numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
    NSDictionary* videoSettings = [NSDictionary
                                   dictionaryWithObject:value forKey:key];
    [captureOutput setVideoSettings:videoSettings];
    self.captureSession = [[AVCaptureSession alloc] init];
    [self.captureSession addInput:captureInput];
    [self.captureSession addOutput:captureOutput];
    [self.captureSession startRunning];
    self.customLayer = [CALayer layer];
    self.customLayer.frame = self.view.bounds;
    self.customLayer.transform = CATransform3DRotate(
                                                     CATransform3DIdentity, M_PI/2.0f, 0, 0, 1);
    self.customLayer.contentsGravity = kCAGravityResizeAspectFill;
    [self.view.layer addSublayer:self.customLayer];
    self.imageView = [[UIImageView alloc] init];
    self.imageView.frame = CGRectMake(0, 0, 100, 100);
    [self.view addSubview:self.imageView];
    self.prevLayer = [AVCaptureVideoPreviewLayer
                      layerWithSession: self.captureSession];
    self.prevLayer.frame = CGRectMake(100, 0, 100, 100);
    self.prevLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
    [self.view.layer addSublayer: self.prevLayer];
}

#pragma mark -
#pragma mark AVCaptureSession delegate
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
       fromConnection:(AVCaptureConnection *)connection
{
    CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
    CVPixelBufferLockBaseAddress(imageBuffer,0);
    uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer);
    size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
    size_t width = CVPixelBufferGetWidth(imageBuffer);
    size_t height = CVPixelBufferGetHeight(imageBuffer);

    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef newContext = CGBitmapContextCreate(baseAddress,
                                                    width, height, 8, bytesPerRow, colorSpace,
                                                    kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
    CGImageRef newImage = CGBitmapContextCreateImage(newContext);

    CGContextRelease(newContext);
    CGColorSpaceRelease(colorSpace);

    [self.customLayer performSelectorOnMainThread:@selector(setContents:)
                                       withObject: (__bridge id) newImage waitUntilDone:YES]; 

    UIImage *image= [UIImage imageWithCGImage:newImage scale:1.0 
                                  orientation:UIImageOrientationRight]; 

    CGImageRelease(newImage);

    [self.imageView performSelectorOnMainThread:@selector(setImage:) 
                                     withObject:image waitUntilDone:YES]; 

    CVPixelBufferUnlockBaseAddress(imageBuffer,0); 
}
</pre>

<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>从以上代码可以看出是通过在AVCaptureSession添加input和output源，startRunning后，通过代理接口来获取图像数据，并通过layer来显示图像数据.</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/02/05/2015-02-05-linphone-iphone代码解读/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/02/05/2015-02-05-linphone-iphone代码解读/" itemprop="url">linphone-iphone代码解读</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-02-05T00:00:00+08:00">
                2015-02-05
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/音视频/" itemprop="url" rel="index">
                    <span itemprop="name">音视频</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>linphone-iphone是Linphone官方提供的iPhone版本源码，源代码结构可谓是相当庞大，不得不做些记录，现记录与此.</p>
<h2 id="流程"><a href="#流程" class="headerlink" title="流程"></a><a href="http://fossies.org/dox/linphone-3.7.0" target="_blank" rel="noopener">流程</a></h2><h3 id="1-初始化startLibLinphone"><a href="#1-初始化startLibLinphone" class="headerlink" title="1. 初始化startLibLinphone"></a>1. 初始化startLibLinphone</h3><ul>
<li>（1）模块初始化，包含mediastreamer2、ilbc、silk、amr、x264、h264、bcg729</li>
</ul>
<pre>
ms_init();
libmsilbc_init();
libmssilk_init(); 
libmsamr_init();
libmsx264_init();
libmsopenh264_init();
libmsbcg729_init();</pre>

<ul>
<li>（2）创建linphone core(createLinphoneCore)</li>
</ul>
<pre>
theLinphoneCore = linphone_core_new_with_config (&linphonec_vtable
                             ,configDb
                             ,self /* user_data */);</pre>
linphonec_vtable为所有回调接口(见LinphoneManager.m)

<pre>
static LinphoneCoreVTable linphonec_vtable = {
.show =NULL,
.call_state_changed =(LinphoneCoreCallStateChangedCb)linphone_iphone_call_state,
.registration_state_changed = linphone_iphone_registration_state,
.notify_presence_received=NULL,
.new_subscription_requested = NULL,
.auth_info_requested = NULL,
.display_status = linphone_iphone_display_status,
.display_message=linphone_iphone_log,
.display_warning=linphone_iphone_log,
.display_url=NULL,
.text_received=NULL,
.message_received=linphone_iphone_message_received,
.dtmf_received=NULL,
   .transfer_state_changed=linphone_iphone_transfer_state_changed,
   .is_composing_received = linphone_iphone_is_composing_received,
   .configuring_status = linphone_iphone_configuring_status_changed,
   .global_state_changed = linphone_iphone_global_state_changed
};</pre>

<p>LinphoneCoreVTable包含:</p>
<pre><code>* global_state_changed 全局状态改变回调
* registration_state_changed 注册状态改变回调
* call_state_changed 呼叫状态改变回调
* ...(详见linphonecore.h)
</code></pre><ul>
<li>（3）初始化audio session</li>
</ul>
<pre>
AVAudioSession *audioSession = [AVAudioSession sharedInstance]    ;
BOOL bAudioInputAvailable= audioSession.inputAvailable    ;
[audioSession setActive:NO error: &err    ]</pre>

<h3 id="2-注册"><a href="#2-注册" class="headerlink" title="2. 注册"></a>2. 注册</h3><ul>
<li>（1）linphone_auth_info_new 生成认证信息</li>
<li>（2）linphone_core_clear_all_auth_info 清空所有认证信息</li>
<li>（3）linphone_core_add_auth_info添加认证信息</li>
</ul>
<h3 id="3-配置项"><a href="#3-配置项" class="headerlink" title="3. 配置项"></a>3. 配置项</h3><p>配置项采用InAppSettings第三方库来实现的，存储于InAppSettings.bundle中得plist文件下，在LinphoneManager初始化会通过migrateFromUserPrefs来同步一次配置项；<br>在退出设置界面时会调用[LinphoneCoreSettingsStore synchronize]来生效配置，如下是一些常用的配置接口:</p>
<pre>
linphone_core_set_sip_transports 设置sip传输协议有TCP、UDP、TLS
linphone_address_set_username 设置用户名
linphone_address_set_domain 设置域名
linphone_auth_info_new 创建认证信息，包含用户名、密码、域名
linphone_core_add_auth_info 添加认证信息
linphone_core_enable_payload_type 音视频开关配置</pre>

<h3 id="4-来电"><a href="#4-来电" class="headerlink" title="4. 来电"></a>4. 来电</h3><p>当有来电时，会触发call_state_changed发生变化（linphonec_vtable），于是会调用回调linphone_iphone_call_state</p>
<pre>
static void linphone_iphone_call_state(LinphoneCore *lc, LinphoneCall* call, LinphoneCallState state,const char* message) {
[(LinphoneManager*)linphone_core_get_user_data(lc) onCall:call StateChanged: state withMessage:  message];
}</pre>

<p>呼叫状态值如下:</p>
<pre>
typedef enum _LinphoneCallState{
LinphoneCallIdle = 0, //初始化状态
LinphoneCallIncomingReceived = 1, //来电
LinphoneCallOutgoingInit = 2, //开始呼出
LinphoneCallOutgoingProgress = 3, //正在处理呼出
LinphoneCallOutgoingRinging = 4, //呼出正在响铃
LinphoneCallOutgoingEarlyMedia = 5,
LinphoneCallConnected = 6, //接通
LinphoneCallStreamsRunning = 7, //媒体流通道构建成功
LinphoneCallPausing = 8, 
LinphoneCallPaused = 9,
LinphoneCallResuming = 10,
LinphoneCallRefered = 11,//有新来电，转出当前回话
LinphoneCallError = 12,
LinphoneCallEnd = 13, //结束
LinphoneCallPausedByRemote = 14, //远程结束
LinphoneCallUpdatedByRemote = 15, //配置更新，如视频开启
LinphoneCallIncomingEarlyMedia = 16,
LinphoneCallUpdating = 17,
LinphoneCallReleased = 18
} LinphoneCallState;</pre>

<h3 id="5-接听"><a href="#5-接听" class="headerlink" title="5. 接听"></a>5. 接听</h3><ul>
<li>弹出IncomingCallViewController</li>
</ul>
<pre>
linphone_iphone_call_state -> [LinphoneManager onCall:StateChanged:withMessage] -> [PhoneMainView callUpdate]->[PhoneMainView displayIncomingCall] -> IncomingCallViewController</pre>

<ul>
<li>点击接听</li>
</ul>
<pre>
onAcceptClick -> [PhoneMainView incomingCallAccepted] -> acceptCall->linphone_core_accept_call_with_params</pre>

<h3 id="6-呼出"><a href="#6-呼出" class="headerlink" title="6. 呼出"></a>6. 呼出</h3><ul>
<li>呼出</li>
</ul>
<pre>
DialerViewController ->[UICallButton touchUp:]-> [LinphoneManager call:displayName:transfer:] -> linphone_core_invite_address_with_params</pre>

<h3 id="7-摄像头设备"><a href="#7-摄像头设备" class="headerlink" title="7. 摄像头设备"></a>7. 摄像头设备</h3><ul>
<li>前置后置</li>
</ul>
<pre>
linphone_core_get_video_devices 获取所有设备号
linphone_core_set_video_device 设置设备号
linphone_core_get_video_device 获取当前设备号</pre>

<h3 id="8-摄像头视频显示"><a href="#8-摄像头视频显示" class="headerlink" title="8. 摄像头视频显示"></a>8. 摄像头视频显示</h3><ul>
<li>摄像头模块初始化</li>
</ul>
<pre>
MSWebCamDesc ms_v4ios_cam_desc = {
"AV Capture",
&ms_v4ios_detect,
&ms_v4ios_cam_init,
&ms_v4ios_create_reader,
NULL
}; </pre>

<p>startLibLinphone -&gt; ms_init -&gt; ms_voip_init -&gt; ms_factory_init_voip -&gt; ms_web_cam_manager_register_desc(ms_web_cam_desc[i]) -&gt; cam_detect -&gt; ms_v4ios_cam_desc.detect -&gt; ms_v4ios_detect</p>
<pre>
 NSArray * array = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
 for(i = 0 ; i < [array count]; i++)
 {
    AVCaptureDevice * device = [array objectAtIndex:i];
     MSWebCam *cam=ms_web_cam_new(&ms_v4ios_cam_desc);
     cam->name= ms_strdup([[device modelID] UTF8String]);
     cam->data = ms_strdup([[device uniqueID] UTF8String]);
     ms_web_cam_manager_add_cam(obj,cam);
 }</pre>

<p>PS:ms_v4ios_cam_desc位于ms_web_cam_descs数组中, MSWebCamManager负责管理所有摄像头</p>
<pre>
struct _MSWebCamManager{
     MSList *cams;
     MSList *descs;
 };
</pre>

<ul>
<li>IOSCapture初始化，设置OUTPUT Capture</li>
</ul>
<pre>
MSFilterDesc ms_ioscapture_desc = {
.id=MS_V4L_ID,
    .name="MSioscapture",
    .text="A video for IOS compatible source filter to stream pictures.",
    .ninputs=0,
  .noutputs=1,
  .category=MS_FILTER_OTHER,
  .init=ioscapture_init,
  .preprocess=ioscapture_preprocess,
  .process=ioscapture_process,
  .postprocess=ioscapture_postprocess,
  .uninit=ioscapture_uninit,
  .methods=methods
}; </pre>

<p>ms_v4ios_create_reader -&gt; ms_filter_new_from_desc(&amp;ms_ioscapture_desc) -&gt; ms_filter_new_from_desc -&gt; ms_factory_create_filter_from_desc -&gt; ms_ioscapture_desc.init -&gt; ioscapture_init -&gt; [IOSCapture initWithFrame:] -&gt; initIOSCapture </p>
<ul>
<li><p>启动摄像头<br>  linphone_core_iterate -&gt; toggle_video_preview -&gt; video_preview_start -&gt; ms_web_cam_create_reader -&gt; ms_v4ios_cam_desc.create_reader -&gt; ms_v4ios_create_reader -&gt; openDevice -&gt; 初始化AVCaptureSession</p>
</li>
<li><p>开始抓拍<br>  video_stream_payload_type_changed(videostream.c) -&gt; mediastream_payload_type_changed(mediastream.c) -&gt; media_stream_change_decoder -&gt; ms_filter_preprocess -&gt; ioscapture_preprocess -&gt; start -&gt; [AVCaptureSession startRunning]<br>PS: 当payload_type发生改变时就会触发video_stream_payload_type_changed（video_stream_start初始化）</p>
</li>
<li><p>视频显示<br>通过代理captureOutput:didOutputSampleBuffer:fromConnection来接收摄像头数据</p>
</li>
</ul>
<h3 id="9-声音"><a href="#9-声音" class="headerlink" title="9. 声音"></a>9. 声音</h3><p>startLibLinphone -&gt; ms_init -&gt; ms_voip_init -&gt; ms_factory_init_voip -&gt; ms_snd_card_manager_register_desc -&gt; card_detect -&gt; au_detect -&gt; ms_snd_card_new_with_name -&gt; au_init</p>
<h3 id="10-发送声音"><a href="#10-发送声音" class="headerlink" title="10. 发送声音"></a>10. 发送声音</h3>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/02/05/2015-02-05-牛逼的ImageMagick/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/02/05/2015-02-05-牛逼的ImageMagick/" itemprop="url">牛逼的ImageMagick</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-02-05T00:00:00+08:00">
                2015-02-05
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/SHELL/" itemprop="url" rel="index">
                    <span itemprop="name">SHELL</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>ImageMagick[1] 是一个免费的创建、编辑、合成图片的软件。可用于格式转换、变换、透明度设置、特效….; 可支持的格式多达89种。</p>
<h2 id="小试牛刀"><a href="#小试牛刀" class="headerlink" title="小试牛刀"></a>小试牛刀</h2><p>若你想将jpg文件转换成bmp、png、psd…, 只有执行如下动作:</p>
<pre>
convert x.jpg x.bmp
</pre>

<p>PS：以前无法是图片转个格式，变个大小，统统都开启PS，现在突然发现酱紫弱爆了</p>
<pre>
下ImageMagick支持至少90种图片格式: A, ART, AVI, AVS, B, BIE, BMP, BMP2, BMP3, C, CACHE, CAPTION, CIN, CIP, CLIP, CLIPBOARD, CMYK, CMYKA, CUR, CUT, DCM, DCX, DNG, DOT, DPS, DPX, EMF, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, FAX, FITS, FPX, FRACTAL, G, G3, GIF, GIF87, GRADIENT, GRAY, HDF, HISTOGRAM, HTM, HTML, ICB, ICO, ICON, JBG, JBIG, JNG, JP2, JPC, JPEG, JPG, JPX, K, LABEL, M, M2V, MAP, MAT, MATTE, MIFF, MNG, MONO, MPC, MPEG, MPG, MSL, MTV, MVG, NULL, O,OTB, P7, PAL, PALM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PFA, PFB, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG24, PNG32, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSD, PTIF, PWP, R, RAS, RGB, RGBA, RGBO, RLA, RLE, SCR, SCT, SFW, SGI, SHTML, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, TIF, TIFF, TILE, TIM, TTC, TTF, TXT, UIL, UYVY, VDA, VICAR, VID, VIFF, VST, WBMP, WMF, WMFWIN32, WMZ, WPG, X, XBM, XC, XCF, XPM, XV, XWD, Y, YCbCr, YCbCrA, YUV
</pre>

<h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><p>这么好用的工具果断装起，安装方法也so easy.</p>
<pre>
sudo brew install ImageMagick
</pre>

<h2 id="使用"><a href="#使用" class="headerlink" title="使用"></a><a href="http://www.imagemagick.org/script/command-line-options.php" target="_blank" rel="noopener">使用</a></h2><h6 id="1-转换格式"><a href="#1-转换格式" class="headerlink" title="1. 转换格式"></a>1. 转换格式</h6><pre>
convert x.jpg x.bmp
</pre>

<h6 id="2-透明"><a href="#2-透明" class="headerlink" title="2. 透明"></a>2. 透明</h6><p>JPG图象是不含有透明通道的，PNG TIG TIG GIF等是具有透明通道的</p>
<pre>
convert -alpha type x.png x1.png
</pre>

<p>常用type</p>
<pre>
Opaque - 不透
Transparent - 透明
</pre>


          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2015/02/02/2015-02-02-MacOSX下编译linphone/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2015/02/02/2015-02-02-MacOSX下编译linphone/" itemprop="url">MacOSX下编译linphone</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-02-02T00:00:00+08:00">
                2015-02-02
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/音视频/" itemprop="url" rel="index">
                    <span itemprop="name">音视频</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>Linphone是一个开源的VOIP框架，利用它提供的库能够快速构建一个VOIP的客户端. 虽然Linphone提供了iPhone版源码，但编译它还是遇到了不少问题，现将记录于此.</p>
<h2 id="依赖库"><a href="#依赖库" class="headerlink" title="依赖库"></a>依赖库</h2><ul>
<li>cunit - c单元测试框架库</li>
<li>silk - skype自己的音频解码器</li>
<li>webrtc - 实时网页即时通信，是一个支持网页浏览器进行实时语音对话或视频对话的API</li>
<li>x264 - 进行H.264/MPEG-4 AVC的视频编码，而不是作为解码器（decoder）之用.</li>
<li>polarssl - 最小巧的ssl代码库。高效、便于移植和集成。尤其适合嵌入式应用</li>
<li>speex - Speex是一套主要针对语音的开源免费，无专利保护的音频压缩格式。Speex工程着力于通过提供一个可以替代高性能语音编解码来降低语音应用输入门槛 </li>
<li>srtp - VoIP网络很不安全，这也是限制VoIP发展的一个考虑因素。为了提供一种策略满足VoIP的安全，SRTP应运而生。所谓SRTP，即安全实时传输协议(Secure Real-time Transport<br>Protocol)，其是在实时传输协议(Real-time Transport Protocol)基础上所定义的一个协<br>议，旨在为单播和多播应用程序中的实时传输协议的数据提供加密、消息认证、完整性保<br>证和重放保护。</li>
<li>ImageMagick - ImageMagick是一套功能强大、稳定而且开源的工具集和开发包，可以用来读、写和处理超过89种基本格式的图片文件，包括流行的TIFF、JPEG、GIF、 PNG、PDF以及PhotoCD等格式。</li>
<li>gsm - gsm音频编解码</li>
<li>libtool - 封装了不同平台动态链接库的差异，为开发人员提供统一接口</li>
<li>bcg729 - g729语音编解码库</li>
<li>belle-sip - SIP协议栈</li>
<li>amr - AMR即自适应多速率压缩（Adaptive multi-Rate compression）是一个使语音编码最优化的专利</li>
<li>ilbc - iLBC是一种专为包交换网络通信设计的编解码，优于目前流行的G.729、G.723.1，对丢包进行了特有处理，即使在丢包率 相当高的网络环境下，仍可获得非常清晰的语音效果。</li>
<li>openh264 - 思科的h264编解码器</li>
<li>antlr3 - 语言识别的一个工具 (ANother Tool for Language Recognition ) 是一种语言工具，它提供了一个框架，可以通过包含 Java, C++, 或 C# 动作（action）的语法描述来构造语言识别器，编译器和解释器。<ul>
<li>安装方法:<br><pre><br>下载jar文件，并拷贝到/usr/share/java目录下<br>sudo cp antlr-3.4-complete.jar /usr/share/java/antlr.jar<br></pre><br><strong> 注意:必须是3.4，否则可能会报_empty不存在 </strong></li>
</ul>
</li>
</ul>
<h2 id="Build-问题汇总"><a href="#Build-问题汇总" class="headerlink" title="Build 问题汇总"></a>Build 问题汇总</h2><h3 id="1-error-C-compiler-cannot-create-executables"><a href="#1-error-C-compiler-cannot-create-executables" class="headerlink" title="1. error: C compiler cannot create executables"></a>1. error: C compiler cannot create executables</h3><h5 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h5><pre>
checking whether the C compiler works... no
configure: error: in `/Users/starnet/Projects/linphone-iphone/submodules/build-i386-apple-darwin/externals/polarssl':
configure: error: C compiler cannot create executables
</pre>

<h5 id="分析"><a href="#分析" class="headerlink" title="分析"></a>分析</h5><pre>
clang -std=c99 -Qunused-arguments -Wno-unknown-warning-option -Wno-unused-command-line-argument-hard-error-in-future  -arch i386  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -mios-simulator-version-min=4.0 -DTARGET_OS_IPHONE=1 -D__IOS -fms-extensions -Dsha256=polarssl_sha256  -Dasm=__asm hello.c 
ld: -pie can only be used when targeting iOS 4.2 or later
clang: error: linker command failed with exit code 1 (use -v to see invocation)
</pre>
修改上述ios-simulator-version-min=4.2即可以通过编译

##### 处理
于是修改submodules/build/iphone-config.site的SDK_VERSION
<pre>
SDK_VERSION_MAJOR=4                                                              
SDK_VERSION=4.2   
</pre>

<h3 id="2-aclocal-error-aclocal-file-‘m4-lt-obsolete-m4’-does-not-exist"><a href="#2-aclocal-error-aclocal-file-‘m4-lt-obsolete-m4’-does-not-exist" class="headerlink" title="2. aclocal: error: aclocal: file ‘m4/lt~obsolete.m4’ does not exist"></a>2. aclocal: error: aclocal: file ‘m4/lt~obsolete.m4’ does not exist</h3><h5 id="问题-1"><a href="#问题-1" class="headerlink" title="问题"></a>问题</h5><pre>
-e  Running autogen for msopus in /Users/starnet/Projects/linphone-iphone/submodules/build/..//externals/opus 
cd /Users/starnet/Projects/linphone-iphone/submodules/build/..//externals/opus && ./autogen.sh
Updating build configuration files, please wait....
aclocal: error: aclocal: file 'm4/lt~obsolete.m4' does not exist
autoreconf: aclocal failed with exit status: 1
</pre>

<h5 id="分析-1"><a href="#分析-1" class="headerlink" title="分析"></a>分析</h5><p>分析发现/opt/local/share/aclocal/lt~obsolete.m4路径不存在，发现/usr/local/share/aclocal/存在，于是建立软连接</p>
<h5 id="处理"><a href="#处理" class="headerlink" title="处理"></a>处理</h5><pre>
sudo ln -s /usr/local/share/aclocal /opt/local/share/
</pre>

<h3 id="3-configure-error-GNU-gettext-tools-not-found-required-for-intltool"><a href="#3-configure-error-GNU-gettext-tools-not-found-required-for-intltool" class="headerlink" title="3. configure: error: GNU gettext tools not found; required for intltool"></a>3. configure: error: GNU gettext tools not found; required for intltool</h3><h5 id="问题-2"><a href="#问题-2" class="headerlink" title="问题"></a>问题</h5><pre>
configure: error: GNU gettext tools not found; required for intltool
</pre>
##### 分析
未安装gettext

##### 处理
<pre>
sudo brew install gettext
sudo ln -s /usr/local/Cellar/gettext/0.19.3_1/bin/msgmerge /usr/local/bin/
sudo ln -s /usr/local/Cellar/gettext/0.19.3_1/bin/msgfmt /usr/local/bin/
sudo ln -s /usr/local/Cellar/gettext/0.19.3_1/bin/xgettext /usr/local/bin/
</pre>

<h3 id="4-‘CoreFoundation-CFUserNotification-h’-file-not-found"><a href="#4-‘CoreFoundation-CFUserNotification-h’-file-not-found" class="headerlink" title="4. ‘CoreFoundation/CFUserNotification.h’ file not found"></a>4. ‘CoreFoundation/CFUserNotification.h’ file not found</h3><h5 id="问题-3"><a href="#问题-3" class="headerlink" title="问题"></a>问题</h5><pre>
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CFNetwork.framework/Headers/CFHost.h:22:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:92:10: fatal error: 
      'CoreFoundation/CFUserNotification.h' file not found
#include <corefoundation cfusernotification.h="">
</corefoundation></pre>

<h5 id="分析-2"><a href="#分析-2" class="headerlink" title="分析"></a>分析</h5><p>查看CoreFoundation.h文件，发现TARGET_OS_IPHONE被重置为0，经过寻找是由于CFBase.h中调用的TargetConditionals.h是来自于MacOSX10.10的SDK下面，后面发现是由于指定了C_INCLUDE_PATH</p>
<pre>
declare -x C_INCLUDE_PATH="/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/"
</pre>
##### 处理
直接export C_INCLUDE_PATH = ""

### 5. error: Libtool library used but 'LIBTOOL' is undefined

##### 问题
<pre>
CUnit/Sources/Automated/Makefile.am:3: error: Libtool library used but 'LIBTOOL' is undefined
CUnit/Sources/Automated/Makefile.am:3:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
CUnit/Sources/Automated/Makefile.am:3:   to 'configure.in' and run 'aclocal' and 'autoconf' again.
CUnit/Sources/Automated/Makefile.am:3:   If 'LT_INIT' is in 'configure.in', make sure
</pre>
##### 分析
aclocal是一个perl脚本程序，扫描configure.ac来创建aclocal.m4文件，以供autoconf来生成configure文件
'LIBTOOL' is undefined是由于aclocal找不到libtool宏，原因可能是没安装libtool或路径不对，aclocal -I可以制定m4文件路径

##### 处理
拷贝libtool下得m4文件到aclocal下
<pre>
sudo cp /usr/local/Cellar/libtool/2.4.2/share/aclocal/* /opt/local/share/aclocal/
</pre>

<h3 id="6-syntax-error-near-unexpected-token-am-api-version-’1-14’’"><a href="#6-syntax-error-near-unexpected-token-am-api-version-’1-14’’" class="headerlink" title="6. syntax error near unexpected token `am__api_version=’1.14’’"></a>6. syntax error near unexpected token `am__api_version=’1.14’’</h3><h5 id="问题-4"><a href="#问题-4" class="headerlink" title="问题"></a>问题</h5><pre>
/Users/starnet/Projects/linphone-iphone/submodules/build/..//belle-sip/configure: line 2637: syntax error near unexpected token \`am__api_version='1.14''
/Users/starnet/Projects/linphone-iphone/submodules/build/..//belle-sip/configure: line 2637: `am__api_version='1.14''
builders.d/belle-sip.mk:27: recipe for target '/Users/starnet/Projects/linphone-iphone/submodules/build/../build-i386-apple-darwin/belle-sip/Makefile' failed
make[1]: *** [/Users/starnet/Projects/linphone-iphone/submodules/build/../build-i386-apple-darwin/belle-sip/Makefile] Error 2
</pre>

<h5 id="分析-3"><a href="#分析-3" class="headerlink" title="分析"></a>分析</h5><p>测试发现是由于PKG_PROG_PKG_CONFIG() 未定义导致的，而PKG_PROG_PKG_CONFIG() 是存在于pkg.m4中（由pkg-config提供）</p>
<h5 id="处理-1"><a href="#处理-1" class="headerlink" title="处理"></a>处理</h5><p>通过aclocal -I或者将pkg.m4拷贝到aclocal的目录下</p>
<pre>
aclocal --print-ac-dir #可以查看aclocal目录
sudo cp /usr/local/Cellar/pkg-config/0.28/share/aclocal/pkg.m4 /opt/local/share/aclocal/
</pre>    

<h3 id="7-syntax-error-near-unexpected-token-MSGFMT-’"><a href="#7-syntax-error-near-unexpected-token-MSGFMT-’" class="headerlink" title="7. syntax error near unexpected token `MSGFMT,’"></a>7. syntax error near unexpected token `MSGFMT,’</h3><h5 id="问题-5"><a href="#问题-5" class="headerlink" title="问题"></a>问题</h5><pre>
/Users/starnet/Projects/linphone-iphone/submodules/build/..//linphone/mediastreamer2/configure: line 17534: syntax error near unexpected token `MSGFMT,'
/Users/starnet/Projects/linphone-iphone/submodules/build/..//linphone/mediastreamer2/configure: line 17534: `        AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,'
configure: error: /Users/starnet/Projects/linphone-iphone/submodules/build/..//linphone/mediastreamer2/configure failed for mediastreamer2
builder-iphone-os.mk:173: recipe for target '/Users/starnet/Projects/linphone-iphone/submodules/build/../build-i386-apple-darwin/linphone/Makefile' failed
make[1]: *** [/Users/starnet/Projects/linphone-iphone/submodules/build/../build-i386-apple-darwin/linphone/Makefile] Error 2
</pre>

<h5 id="分析-4"><a href="#分析-4" class="headerlink" title="分析"></a>分析</h5><p>测试发现是AM_PATH_PROG_WITH_TEST未定义，这个是在gettext的m4文件中定义</p>
<h5 id="处理-2"><a href="#处理-2" class="headerlink" title="处理"></a>处理</h5><p>拷贝m4到aclocal下</p>
<pre>
sudo cp /usr/local/Cellar/gettext/0.19.3_1/share/aclocal/* /opt/local/share/aclocal
</pre>

<h3 id="8-ld-illegal-text-relocation-to-‘-vp8-dequant-idct-add-mmx’"><a href="#8-ld-illegal-text-relocation-to-‘-vp8-dequant-idct-add-mmx’" class="headerlink" title="8. ld: illegal text-relocation to ‘_vp8_dequant_idct_add_mmx’"></a>8. ld: illegal text-relocation to ‘_vp8_dequant_idct_add_mmx’</h3><h5 id="问题-6"><a href="#问题-6" class="headerlink" title="问题"></a>问题</h5><pre>
ld: illegal text-relocation to '_vp8_dequant_idct_add_mmx' in /Users/starnet/Projects/linphone-iphone/liblinphone-sdk/i386-apple-darwin/lib/libvpx.a(dequantize_mmx.asm.o) from '_vp8_dequant_idct_add_mmx' in /Users/starnet/Projects/linphone-iphone/liblinphone-sdk/i386-apple-darwin/lib/libvpx.a(dequantize_mmx.asm.o) for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
</pre>

<h5 id="分析-5"><a href="#分析-5" class="headerlink" title="分析"></a>分析</h5><p><a href="http://stackoverflow.com/questions/6650178/illegal-text-reloc-to-non-lazy-ptr-error-while-building-in-xcode-4-with-libav-l" target="_blank" rel="noopener">这里</a>有关于illegal text-relocation的说明<br>大致意思：当一个全局变量被编译到动态库中，而第三方asm代码需要引用该变量时，连接器会把相对地址付给相应引用，当他们处于一个连接单元时，则不会有问题，当不同单元则就会出问题；应该是连接器的一个bug</p>
<h5 id="处理-3"><a href="#处理-3" class="headerlink" title="处理"></a>处理</h5><p>(1) 编辑linphone/mediastreamer2/tester/Makefile.am, 为AM_LDFLAGS添加-read_only_relocs suppress</p>
<pre>
 AM_LDFLAGS=-no-undefined -export-dynamic -read_only_relocs suppress
</pre>
(2) 编辑linphone/coreapi/Makefile.am
<pre>
AM_LDFLAGS= -read_only_relocs suppress
</pre>

<h3 id="9-extract-cfile-awk无法下载"><a href="#9-extract-cfile-awk无法下载" class="headerlink" title="9. extract-cfile.awk无法下载"></a>9. extract-cfile.awk无法下载</h3><h5 id="问题-7"><a href="#问题-7" class="headerlink" title="问题"></a>问题</h5><pre>
/usr/local/bin/wget --no-check-certificate http://www.webrtc.org/ilbc-freeware/ilbc-source-code-and-utili/ilbc-utilities/extract-cfile.awk -O extract-cfile.awk
--2015-02-04 12:59:41--  http://www.webrtc.org/ilbc-freeware/ilbc-source-code-and-utili/ilbc-utilities/extract-cfile.awk
Resolving www.webrtc.org... 74.125.23.121
Connecting to www.webrtc.org|74.125.23.121|:80... 
</pre>

<h5 id="分析-6"><a href="#分析-6" class="headerlink" title="分析"></a>分析</h5><p>链接不存在</p>
<h5 id="处理-4"><a href="#处理-4" class="headerlink" title="处理"></a>处理</h5><p>到<a href="http://www.ilbcfreeware.org下载extract-cfile.txt，拷贝到上传到可用的服务器，这里我上传到github，地址http://7ximmr.com1.z0.glb.clouddn.com/extract-cfile.awk" target="_blank" rel="noopener">www.ilbcfreeware.org下载extract-cfile.txt，拷贝到上传到可用的服务器，这里我上传到github，地址http://7ximmr.com1.z0.glb.clouddn.com/extract-cfile.awk</a><br>编辑submodules/libilbc-rfc3951/downloads/Makefile.am</p>
<pre>
extract_script = extract-cfile.awk
extract_script_url = https://github.com/wenva/wenva.github.com/raw/master/resource/$(extract_script)
</pre>

<h3 id="10-No-working-C-compiler-found"><a href="#10-No-working-C-compiler-found" class="headerlink" title="10. No working C compiler found."></a>10. No working C compiler found.</h3><h5 id="问题-8"><a href="#问题-8" class="headerlink" title="问题"></a>问题</h5><pre>
./configure --prefix=/Users/starnet/Projects/linphone-iphone/submodules/build/..//../liblinphone-sdk/i386-apple-darwin  --host=i386-apple-darwin --enable-static --enable-pic --cross-prefix=$SDK_BIN_PATH/ --extra-ldflags="$COMMON_FLAGS" --extra-cflags="$COMMON_FLAGS "
Loading config.site for iPhone platform=Simulator version=4.2
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
Selecting SDK path = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
No working C compiler found.
</pre>

<h5 id="分析-7"><a href="#分析-7" class="headerlink" title="分析"></a>分析</h5><p>查看configure文件</p>
<pre>
...
if $cc_cmd >conftest.log 2>&1; then                                          
...
</pre>
即结果导入conftest.log, 发现如下
<pre>
clang: error: unknown argument: '-falign-loops=16' 
</pre>
即clang不支持-falign-loops

##### 处理

删除submodules/build-i386-apple-darwin/externals/x264
编辑submodules/externals/x264/configure，去除-falign-loops
<pre>
457     darwin*)                                                                     
458         SYS="MACOSX"                                                             
459  #       CFLAGS="$CFLAGS -falign-loops=16"                                       
460         libm="-lm"         
</pre>

<h3 id="11-compile-unable-to-infer-tagged-configuration"><a href="#11-compile-unable-to-infer-tagged-configuration" class="headerlink" title="11. compile: unable to infer tagged configuration"></a>11. compile: unable to infer tagged configuration</h3><h5 id="问题-9"><a href="#问题-9" class="headerlink" title="问题"></a>问题</h5><pre>
libtool: compile: unable to infer tagged configuration
libtool: compile: specify a tag with `--tag'
Makefile:1039: recipe for target 'backgroundtask.lo' failed
make[1]: *** [backgroundtask.lo] Error 1
</pre>

<h5 id="分析-8"><a href="#分析-8" class="headerlink" title="分析"></a>分析</h5><p>如果使用的compiler不是gcc, libtool会认错，需要添加参数–tag=CXX或–tag=CC</p>
<h5 id="处理-5"><a href="#处理-5" class="headerlink" title="处理"></a>处理</h5><pre>
LTOBJCCOMPILE = $(LIBTOOL) $(AM_V_lt) <font color="ff0000"> --tag=CC </font>$(AM_LIBTOOLFLAGS) \ 
...
OBJCLINK = $(LIBTOOL) $(AM_V_lt) <font color="ff0000"> --tag=CC </font> $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS)
...
</pre>

<h3 id="12-Applications-Xcode-app-Contents-Developer-Platforms-iPhoneSimulator-platform-Developer-usr-bin-strings-No-such-file-or-directory"><a href="#12-Applications-Xcode-app-Contents-Developer-Platforms-iPhoneSimulator-platform-Developer-usr-bin-strings-No-such-file-or-directory" class="headerlink" title="12. /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/strings: No such file or directory"></a>12. /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/strings: No such file or directory</h3><pre>
Selecting SDK path = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.2.sdk
./configure: line 730: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/strings: No such file or directory
./configure: line 732: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/strings: No such file or directory
endian test failed
builders.d/x264.mk:53: recipe for target '/Users/starnet/Projects/linphone-iphone/submodules/build/../build-i386-apple-darwin/externals/x264/config.mak' failed
</pre>
解决：
建立软连接
<pre>
sudo ln -s /Applications/Xcode.app/Contents/Developer//Toolchains/XcodeDefault.xctoolchain/usr/bin/strings /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/
</pre>

<h3 id="13-ld-illegal-text-relocation-to-‘-x264-cabac-range-lps’"><a href="#13-ld-illegal-text-relocation-to-‘-x264-cabac-range-lps’" class="headerlink" title="13.ld: illegal text-relocation to ‘_x264_cabac_range_lps’"></a>13.ld: illegal text-relocation to ‘_x264_cabac_range_lps’</h3><p>问题</p>
<pre>
ld: illegal text-relocation to '_x264_cabac_range_lps' in libx264.a(cabac.o) from '_x264_cabac_encode_decision_asm' in libx264.a(cabac-a.o) for architecture i386
</pre>
编辑submodules/externals/x264/configure
<pre>
LDFLAGS="$LDFLAGS -read_only_relocs suppress" 
</pre>

<h2 id="运行问题汇总"><a href="#运行问题汇总" class="headerlink" title="运行问题汇总"></a>运行问题汇总</h2><h3 id="1-登录时crash"><a href="#1-登录时crash" class="headerlink" title="1. 登录时crash"></a>1. 登录时crash</h3><h5 id="问题-10"><a href="#问题-10" class="headerlink" title="问题"></a>问题</h5><pre>
belle_sip_object_vptr_t *vptr=obj->vptr; 崩溃
</pre>

<h5 id="分析-9"><a href="#分析-9" class="headerlink" title="分析"></a>分析</h5><p>调用栈:从下到上</p>
<pre>
belle_sip_object_marshal
sal_address_as_string
sal_op_set_route_address
sal_op_add_route_address
linphone_transfer_routes_to_op
linphone_configure_op
linphone_proxy_config_register
linphone_proxy_config_update
ms_list_for_each
proxy_update
linphone_core_iterate
[LinphoneManager iterate]
</pre>

<p>相关结构体</p>
<pre>
struct _belle_sip_object_vptr{
    belle_sip_type_id_t id;
    const char *type_name;
    int initially_unowned;
    belle_sip_object_get_vptr_t get_parent;
    struct belle_sip_interface_desc **interfaces; /*NULL terminated table of */
    belle_sip_object_destroy_t destroy;
    belle_sip_object_clone_t clone;
    belle_sip_object_marshal_t marshal;
    int tostring_bufsize_hint; /*optimization: you can suggest here the typical size for a to_string() result.*/
};

struct _belle_sip_object{
    belle_sip_object_vptr_t *vptr;
    size_t size;
    int ref;
    char* name;
    struct weak_ref *weak_refs;
    struct belle_sip_object_pool *pool;
    struct _belle_sip_list *pool_iterator;
    struct _belle_sip_list *data_store;
};

</pre>

<p>通过分析发现是由于sal_address_destroy释放一个空指针，应该是linphone的bug，目前通过如下方式解决:<br>修改submodules/linphone/coreapi/bellesip_sal/sal_address_impl.c </p>
<pre>
void sal_address_destroy(SalAddress *addr){
    if (addr) sal_address_unref(addr);
}
</pre>



<h3 id="2-ortp-warning-There-is-no-object-pool-created-in-thread-43003904-Use-belle-sip-object-pool-push-to-create-one-Unowned-objects-not-unref’d-will-be-leaked"><a href="#2-ortp-warning-There-is-no-object-pool-created-in-thread-43003904-Use-belle-sip-object-pool-push-to-create-one-Unowned-objects-not-unref’d-will-be-leaked" class="headerlink" title="2. ortp-warning-There is no object pool created in thread [43003904]. Use belle_sip_object_pool_push() to create one. Unowned objects not unref’d will be leaked."></a>2. ortp-warning-There is no object pool created in thread [43003904]. Use belle_sip_object_pool_push() to create one. Unowned objects not unref’d will be leaked.</h3><p>定位在belle-sip/belle_sip_object.c -&gt; get_current_pool_stack -》 belle_sip_thread_getspecific</p>
<p>belle_sip_thread_getspecific在传入相同值，返回的结果有时会不一样，部分情况返回NULL，于是导致后面的代码出错，目前暂未找到根本原因，暂时对后面crash的地方进行参数判断.</p>
<ul>
<li>belle_sip_header_address_get_uri<pre>
belle_sip_uri_t* belle_sip_header_address_get_uri(const belle_sip_header_address_t* address) {
  return address ? address->uri : NULL;//此处添加判断
}
</pre></li>
<li><p>sal_address_impl.c -&gt; sal_address_as_string_uri_only</p>
<pre>
char *sal_address_as_string_uri_only(const SalAddress *addr){
  belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr);
  belle_sip_uri_t* uri = belle_sip_header_address_get_uri(header_addr);
  if (!uri) return NULL;//此次添加判断

  char tmp[1024]={0};
  size_t off=0;
  belle_sip_object_marshal((belle_sip_object_t*)uri,tmp,sizeof(tmp),&off);
  return ms_strdup(tmp);
}
</pre>

</li>
</ul>
<p>此问题已解决，详情猛戳<a href="http://wenva.github.io/ios/2015/04/08/%E7%BA%BF%E7%A8%8B%E5%B1%80%E9%83%A8%E5%AD%98%E5%82%A8.html" target="_blank" rel="noopener">这里</a></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2014/12/22/2014-12-22-UITabbarItem图标要求/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2014/12/22/2014-12-22-UITabbarItem图标要求/" itemprop="url">UITabbarItem图标要求</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2014-12-22T00:00:00+08:00">
                2014-12-22
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/IOS/" itemprop="url" rel="index">
                    <span itemprop="name">IOS</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p><img src="http://www.2cto.com/uploadfile/2012/0915/20120915045908604.png" alt="image"></p>
<ul>
<li>图标需要同时存在透明和非透明色</li>
<li>单色的非透明色将被全部覆盖，选中为蓝色，非选中为灰色</li>
</ul>
<h2 id="自定义选中图"><a href="#自定义选中图" class="headerlink" title="自定义选中图"></a>自定义选中图</h2><p>iOS7.0 后提供自定义选中图</p>
<pre>
@property(nonatomic,retain) UIImage *selectedImage NS_AVAILABLE_IOS(7_0);
</pre>
对于selectedImage是需要设置渲染模式（同样针对image），可以在API文档中查看
<pre>
By default, the actual selected image is automatically created from the alpha values in the source image. To prevent system coloring, provide images with UIImageRenderingModeAlwaysOriginal.
</pre>

<p>于是我们可以通过UIImage提供的imageWithRenderingMode来进行设置</p>
<h3 id="Demo"><a href="#Demo" class="headerlink" title="Demo"></a>Demo</h3><pre>
    self.tabBar.backgroundImage = IMG(@"tabbar_background");
    [self.tabBar setShadowImage:[[UIImage alloc] init]];// 去除边框

    NSArray* images = @[@"tabbar_invatation_icon", @"tabbar_home_icon", @"tabbar_monitor_icon"];
    NSArray* selectedImages = @[@"tabbar_invatation_icon_h", @"tabbar_home_icon_h", @"tabbar_monitor_icon_h"];
    NSArray* titles = @[@"invatation", @"home", @"monitor"];
    int i = 0;
    for (UITabBarItem* item in self.tabBar.items) {
        item.image = [[UIImage imageNamed:images[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        item.selectedImage = [[UIImage imageNamed:selectedImages[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        item.title = GET_STRING(titles[i]);
        i++;
    }
</pre>


          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2014/12/10/2014-12-10-ObjC探索之@符/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2014/12/10/2014-12-10-ObjC探索之@符/" itemprop="url">ObjC探索之@符</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2014-12-10T00:00:00+08:00">
                2014-12-10
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/IOS/" itemprop="url" rel="index">
                    <span itemprop="name">IOS</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>程序猿可能没见过猪跑，但必定会认识”hello world”, 不论是教科书还是各种入门教程，都是以hello world来开始一门新语言的学习，ObjC也不例外。在ObjC的世界里，第一眼见到的可能是如下内容:</p>
<pre>
int main(int argc, const char * argv[]) {
    NSLog(@"hello world");
    return 0;
}
</pre>
学过C语言的应该都比较清楚这其中的各面，唯一困惑的应该是@符号，这是何物？为何需要在字符串加上@？？？心中不免留下千万个问号。那么我们讲为你一一解开谜底。

## 从函数声明理解
通过查找官方API可以发现NSLog的声明:
<pre>
void NSLog(NSString *format, ...)
</pre>
从以上函数声明可以看出实参`@"hello world"`应该是个NSString类型，于是我们推断出此处@的作用应该是将char字符串转换为NSString，即编译器编译时将@带的字符串转化为NSString.

## 从C语言角度理解
大家都知道C中是没有对象的概念，只有结构体这一说，那么如何实现的呢？下面我将为你还原真相，在此之前先学习下如何将.m文件还原成.cpp文件.
<pre>
clang -rewrite-objc main.m
</pre>
通过以上方式，就可以将objc转化成cpp. 针对上述的hello world我们可以得到如下文件内容:(这里只列出重要内容)
<pre>
...

struct __NSConstantStringImpl {
  int *isa;
  int flags;
  char *str;
  long length;
};

...

static __NSConstantStringImpl __NSConstantStringImpl__var_folders_ls_0tjr4wp56kxgjwjr9l2qfjw00000gp_T_main_078c9f_mi_0 __attribute__ ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8,"hello world",11};

...

int main(int argc, const char * argv[]) {
    /* @autoreleasepool */ { __AtAutoreleasePool __autoreleasepool; 
        NSLog((NSString *)&__NSConstantStringImpl__var_folders_ls_0tjr4wp56kxgjwjr9l2qfjw00000gp_T_main_078c9f_mi_0);
    }
    return 0;
}

...

</pre>


          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2014/11/19/2014-11-19-macosx常用工具/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2014/11/19/2014-11-19-macosx常用工具/" itemprop="url">MacOSX常用工具</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2014-11-19T00:00:00+08:00">
                2014-11-19
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/工具/" itemprop="url" rel="index">
                    <span itemprop="name">工具</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>这里将记录我在使用MacOSX过程中，需要设计到的工具.</p>
<h2 id="编辑类"><a href="#编辑类" class="headerlink" title="编辑类"></a>编辑类</h2><ul>
<li>Mou - Markdown编辑工具</li>
<li>Sublime Text - 代码编辑工具</li>
<li>TextWrangler - 文本编辑工具</li>
<li>OmniGraffle - 流程图、框图工具</li>
</ul>
<h2 id="开发类"><a href="#开发类" class="headerlink" title="开发类"></a>开发类</h2><ul>
<li>XCode - iOS APP和Mac软件开发工具<ul>
<li><a href="http://alcatraz.io/" target="_blank" rel="noopener">Alcatraz</a> - 插件管理</li>
<li>VVDocumenter - 注释插件</li>
</ul>
</li>
<li>Cocoapod - 第三方库管理工具</li>
<li>PyCharm - Python IDE</li>
<li>SourceTree - Git客户端</li>
<li>MergeDiff - Git 解决冲突<pre>
git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd "/Applications/DiffMerge.app/Contents/MacOS/diffmerge --merge --result=\$MERGED \$LOCAL \$BASE \$REMOTE"
git config --global mergetool.keepBackup false
git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd "/Applications/DiffMerge.app/Contents/MacOS/diffmerge \$LOCAL \$REMOTE"
</pre></li>
<li>Android Studio - Android开发IDE</li>
</ul>
<h2 id="常用软件"><a href="#常用软件" class="headerlink" title="常用软件"></a>常用软件</h2><ul>
<li>Keynote - Mac版PPT</li>
<li>Pages - Mac版Word</li>
<li>Numbers - Mac版Excel</li>
<li>Foxmail - 邮箱工具</li>
<li>The Unarchiver - rar解压工具</li>
<li>Evernote - 日志</li>
<li>Firefox - 浏览器<ul>
<li>Firebug - 网页分析插件</li>
<li>Vimperator - <a href="http://pic002.cnblogs.com/images/2010/175824/2010110310103424.jpg" target="_blank" rel="noopener">类vim操作</a></li>
<li>Add to Search Bar - 添加搜索引擎</li>
</ul>
</li>
<li>MPlayerX - 媒体播放器</li>
<li>Alfred - 快速查找启动应用程序</li>
<li>Wireshark - 抓包工具</li>
<li>iSee - 图片浏览器</li>
<li>Sip - 取色工具</li>
<li>Skitch - 图片批注工具</li>
<li>010 Editor - 16进制编辑器</li>
<li>Chicken - VNC工具</li>
<li>SecureCRT - 串口查看工具</li>
<li>Pocket - 网页缓存</li>
<li>FileZilla - FTP客户端</li>
<li>SDFormatter - SD格式化工具</li>
<li>Microsoft Office - 办公软件</li>
<li>OmniPlan - 任务安排</li>
<li>OmniFocus - GTD工具</li>
<li>iTool - iOS设备同步管理工具</li>
<li>Thunder - 迅雷</li>
<li>QQ - 通讯</li>
<li>RemoteDesktopConnection - 连接Window系统</li>
<li>licecap - gif生成</li>
<li>Paintbrush - 画刷工具</li>
<li>VOX - 无损音乐播放器</li>
<li>Serviio - uPnP服务器</li>
<li>AirServer - AirPlay服务器</li>
<li>ShadowSocks - 翻墙必备</li>
<li>DaisyDisk - 磁盘清理工具</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/blog/page/18/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/blog/">1</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/18/">18</a><span class="page-number current">19</span><a class="page-number" href="/blog/page/20/">20</a><a class="extend next" rel="next" href="/blog/page/20/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">smallmuou</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">197</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/blog/categories/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/smallmuou" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-globe"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">smallmuou</span>

  
</div>

    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

    <span id="busuanzi_container_site_pv">总访问量<span id="busuanzi_value_site_pv"></span>次</span>
    <span class="post-meta-divider">|</span>



  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  

  

  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
